package cn.csc.module.shoppingCard.dal.mysql.points;

import java.util.*;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.module.shoppingCard.dal.dataobject.points.CardPointsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csc.module.shoppingCard.controller.admin.points.vo.*;

/**
 * 购物卡积分 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface CardPointsMapper extends BaseMapperX<CardPointsDO> {

    default PageResult<CardPointsDO> selectPage(CardPointsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CardPointsDO>()
                .eqIfPresent(CardPointsDO::getCardId, reqVO.getCardId())
                .eqIfPresent(CardPointsDO::getPoints, reqVO.getPoints())
                .eqIfPresent(CardPointsDO::getSource, reqVO.getSource())
                .betweenIfPresent(CardPointsDO::getExpireTime, reqVO.getExpireTime())
                .betweenIfPresent(CardPointsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CardPointsDO::getId));
    }

    default List<CardPointsDO> selectList(CardPointsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CardPointsDO>()
                .eqIfPresent(CardPointsDO::getCardId, reqVO.getCardId())
                .eqIfPresent(CardPointsDO::getPoints, reqVO.getPoints())
                .eqIfPresent(CardPointsDO::getSource, reqVO.getSource())
                .betweenIfPresent(CardPointsDO::getExpireTime, reqVO.getExpireTime())
                .betweenIfPresent(CardPointsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CardPointsDO::getId));
    }

}
